// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed class MlGetModelSnapshotsRequestParameters : RequestParameters<MlGetModelSnapshotsRequestParameters>
	{
		[JsonIgnore]
		public int? From { get => Q<int?>("from"); set => Q("from", value); }

		[JsonIgnore]
		public int? Size { get => Q<int?>("size"); set => Q("size", value); }
	}

	public sealed partial class MlGetModelSnapshotsRequest : PlainRequestBase<MlGetModelSnapshotsRequestParameters>
	{
		public MlGetModelSnapshotsRequest(Elastic.Clients.Elasticsearch.Id job_id, Elastic.Clients.Elasticsearch.Id? snapshot_id) : base(r => r.Required("job_id", job_id).Optional("snapshot_id", snapshot_id))
		{
		}

		public MlGetModelSnapshotsRequest(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningGetModelSnapshots;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonIgnore]
		public int? From { get => Q<int?>("from"); set => Q("from", value); }

		[JsonIgnore]
		public int? Size { get => Q<int?>("size"); set => Q("size", value); }

		[JsonInclude]
		[JsonPropertyName("desc")]
		public bool? Desc { get; set; }

		[JsonInclude]
		[JsonPropertyName("end")]
		public DateTimeOffset? End { get; set; }

		[JsonInclude]
		[JsonPropertyName("page")]
		public Elastic.Clients.Elasticsearch.Ml.Page? Page { get; set; }

		[JsonInclude]
		[JsonPropertyName("sort")]
		public Elastic.Clients.Elasticsearch.Field? Sort { get; set; }

		[JsonInclude]
		[JsonPropertyName("start")]
		public DateTimeOffset? Start { get; set; }
	}

	public sealed partial class MlGetModelSnapshotsRequestDescriptor<TDocument> : RequestDescriptorBase<MlGetModelSnapshotsRequestDescriptor<TDocument>, MlGetModelSnapshotsRequestParameters>
	{
		internal MlGetModelSnapshotsRequestDescriptor(Action<MlGetModelSnapshotsRequestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public MlGetModelSnapshotsRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id, Elastic.Clients.Elasticsearch.Id? snapshot_id) : base(r => r.Required("job_id", job_id).Optional("snapshot_id", snapshot_id))
		{
		}

		public MlGetModelSnapshotsRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal MlGetModelSnapshotsRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningGetModelSnapshots;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlGetModelSnapshotsRequestDescriptor<TDocument> From(int? from) => Qs("from", from);
		public MlGetModelSnapshotsRequestDescriptor<TDocument> Size(int? size) => Qs("size", size);
		public MlGetModelSnapshotsRequestDescriptor<TDocument> JobId(Elastic.Clients.Elasticsearch.Id job_id)
		{
			RouteValues.Required("job_id", job_id);
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> SnapshotId(Elastic.Clients.Elasticsearch.Id? snapshot_id)
		{
			RouteValues.Optional("snapshot_id", snapshot_id);
			return Self;
		}

		private bool? DescValue { get; set; }

		private DateTimeOffset? EndValue { get; set; }

		private Elastic.Clients.Elasticsearch.Ml.Page? PageValue { get; set; }

		private PageDescriptor PageDescriptor { get; set; }

		private Action<PageDescriptor> PageDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Field? SortValue { get; set; }

		private DateTimeOffset? StartValue { get; set; }

		public MlGetModelSnapshotsRequestDescriptor<TDocument> Desc(bool? desc = true)
		{
			DescValue = desc;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> End(DateTimeOffset? end)
		{
			EndValue = end;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> Page(Elastic.Clients.Elasticsearch.Ml.Page? page)
		{
			PageDescriptor = null;
			PageDescriptorAction = null;
			PageValue = page;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> Page(PageDescriptor descriptor)
		{
			PageValue = null;
			PageDescriptorAction = null;
			PageDescriptor = descriptor;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> Page(Action<PageDescriptor> configure)
		{
			PageValue = null;
			PageDescriptor = null;
			PageDescriptorAction = configure;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> Sort(Elastic.Clients.Elasticsearch.Field? sort)
		{
			SortValue = sort;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> Sort<TValue>(Expression<Func<TDocument, TValue>> sort)
		{
			SortValue = sort;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor<TDocument> Start(DateTimeOffset? start)
		{
			StartValue = start;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (DescValue.HasValue)
			{
				writer.WritePropertyName("desc");
				writer.WriteBooleanValue(DescValue.Value);
			}

			if (EndValue is not null)
			{
				writer.WritePropertyName("end");
				JsonSerializer.Serialize(writer, EndValue, options);
			}

			if (PageDescriptor is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, PageDescriptor, options);
			}
			else if (PageDescriptorAction is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, new PageDescriptor(PageDescriptorAction), options);
			}
			else if (PageValue is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, PageValue, options);
			}

			if (SortValue is not null)
			{
				writer.WritePropertyName("sort");
				JsonSerializer.Serialize(writer, SortValue, options);
			}

			if (StartValue is not null)
			{
				writer.WritePropertyName("start");
				JsonSerializer.Serialize(writer, StartValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class MlGetModelSnapshotsRequestDescriptor : RequestDescriptorBase<MlGetModelSnapshotsRequestDescriptor, MlGetModelSnapshotsRequestParameters>
	{
		internal MlGetModelSnapshotsRequestDescriptor(Action<MlGetModelSnapshotsRequestDescriptor> configure) => configure.Invoke(this);
		public MlGetModelSnapshotsRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id, Elastic.Clients.Elasticsearch.Id? snapshot_id) : base(r => r.Required("job_id", job_id).Optional("snapshot_id", snapshot_id))
		{
		}

		public MlGetModelSnapshotsRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal MlGetModelSnapshotsRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningGetModelSnapshots;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlGetModelSnapshotsRequestDescriptor From(int? from) => Qs("from", from);
		public MlGetModelSnapshotsRequestDescriptor Size(int? size) => Qs("size", size);
		public MlGetModelSnapshotsRequestDescriptor JobId(Elastic.Clients.Elasticsearch.Id job_id)
		{
			RouteValues.Required("job_id", job_id);
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor SnapshotId(Elastic.Clients.Elasticsearch.Id? snapshot_id)
		{
			RouteValues.Optional("snapshot_id", snapshot_id);
			return Self;
		}

		private bool? DescValue { get; set; }

		private DateTimeOffset? EndValue { get; set; }

		private Elastic.Clients.Elasticsearch.Ml.Page? PageValue { get; set; }

		private PageDescriptor PageDescriptor { get; set; }

		private Action<PageDescriptor> PageDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Field? SortValue { get; set; }

		private DateTimeOffset? StartValue { get; set; }

		public MlGetModelSnapshotsRequestDescriptor Desc(bool? desc = true)
		{
			DescValue = desc;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor End(DateTimeOffset? end)
		{
			EndValue = end;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor Page(Elastic.Clients.Elasticsearch.Ml.Page? page)
		{
			PageDescriptor = null;
			PageDescriptorAction = null;
			PageValue = page;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor Page(PageDescriptor descriptor)
		{
			PageValue = null;
			PageDescriptorAction = null;
			PageDescriptor = descriptor;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor Page(Action<PageDescriptor> configure)
		{
			PageValue = null;
			PageDescriptor = null;
			PageDescriptorAction = configure;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor Sort(Elastic.Clients.Elasticsearch.Field? sort)
		{
			SortValue = sort;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor Sort<TDocument, TValue>(Expression<Func<TDocument, TValue>> sort)
		{
			SortValue = sort;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor Sort<TDocument>(Expression<Func<TDocument, object>> sort)
		{
			SortValue = sort;
			return Self;
		}

		public MlGetModelSnapshotsRequestDescriptor Start(DateTimeOffset? start)
		{
			StartValue = start;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (DescValue.HasValue)
			{
				writer.WritePropertyName("desc");
				writer.WriteBooleanValue(DescValue.Value);
			}

			if (EndValue is not null)
			{
				writer.WritePropertyName("end");
				JsonSerializer.Serialize(writer, EndValue, options);
			}

			if (PageDescriptor is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, PageDescriptor, options);
			}
			else if (PageDescriptorAction is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, new PageDescriptor(PageDescriptorAction), options);
			}
			else if (PageValue is not null)
			{
				writer.WritePropertyName("page");
				JsonSerializer.Serialize(writer, PageValue, options);
			}

			if (SortValue is not null)
			{
				writer.WritePropertyName("sort");
				JsonSerializer.Serialize(writer, SortValue, options);
			}

			if (StartValue is not null)
			{
				writer.WritePropertyName("start");
				JsonSerializer.Serialize(writer, StartValue, options);
			}

			writer.WriteEndObject();
		}
	}
}